package com.nintendo.controller;

import com.nintendo.pojo.bo.CommentBO;
import com.nintendo.pojo.bo.FriendCircleBO;
import com.nintendo.pojo.vo.FriendCircleVO;
import com.nintendo.result.GraceJSONResult;
import com.nintendo.service.CommentService;
import com.nintendo.service.FriendCircleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/circles")
public class CircleController {
    @Autowired
    private FriendCircleService friendCircleService;
    @Autowired
    private CommentService commentService;
    /**
     * 查询好友和本人的朋友圈信息
     */
    @PostMapping("/findCirclesByMyId")
    public GraceJSONResult findCirclesByMyId(HttpServletRequest request) {
        List<FriendCircleVO> friendCircleVosList = friendCircleService.findCirclesByMyId(request);
        return GraceJSONResult.ok(friendCircleVosList);
    }
    @PostMapping("/publish")
    public GraceJSONResult publishCircle(@RequestBody FriendCircleBO friendCircleBO,HttpServletRequest request){
        friendCircleService.publishCircle(friendCircleBO,request);
        return GraceJSONResult.ok();
    }
    /**
     * 点赞/取消点赞
     */
    @PostMapping("/like")
    public GraceJSONResult circleLike(@RequestParam("circleId") String friendCircleId,
                                      @RequestParam("like")Boolean doILike,
                                      HttpServletRequest request){
        friendCircleService.circleLike(friendCircleId,doILike,request);
        return GraceJSONResult.ok();
    }
    /**
     * 评论
     */
    @PostMapping("/doComment")
    public GraceJSONResult doComment(@RequestBody CommentBO commentBO,HttpServletRequest request){
        commentService.doComment(commentBO,request);
        return GraceJSONResult.ok();
    }
}
